***************************************************************
*Author: Claudine Gay
*Created: Apr 30, 2010
*Modified: Mar 30, 2011
*Purpose: Recode variables from raw TESS data file
***************************************************************

cd "/Users/cgay/Documents/My Documents/Linked Fate/TESS DATA"

use tess2_011_hochschild_final_data.dta

*Recode Group A (xtess011=1; unprimed, race first)

recode a2 2=0
recode a3 3=0 2=1 1=2
gen a_lf_race=a2+a3
replace a_lf_race=0 if a2==0
replace a_lf_race=1 if a2==1 & a3==.
label variable a_lf_race "Group A: Race Linked Fate: a2 & a3"

recode a4 2=0
recode a5 3=0 2=1 1=2
gen a_lf_nonrace=a4+a5 
replace a_lf_nonrace=0 if a4==0
replace a_lf_nonrace=1 if a4==1 & a5==.
gen a_lf_gender=a_lf_nonrace if mrk_a4==1
gen a_lf_religion=a_lf_nonrace if mrk_a4==2
gen a_lf_class=a_lf_nonrace if mrk_a4==3
label variable a_lf_nonrace "Group A: Non-Race Linked Fate: a4 & a5"
label variable a_lf_gender "Group A: Gender Linked Fate: a4 & a5, if mrk_a4=1"
label variable a_lf_religion "Group A: Religion Linked Fate: a4 & a5, if mrk_a4=2"
label variable a_lf_class "Group A: Class Linked Fate: a4 & a5, if mrk_a4=3"

*Recode Group B (xtess011=2; unprimed, nonrace first)

recode b2 2=0
recode b3 3=0 2=1 1=2
gen b_lf_nonrace=b2+b3
replace b_lf_nonrace=0 if b2==0
replace b_lf_nonrace=1 if b2==1 & b3==.
gen b_lf_gender=b_lf_nonrace if mrk_b2==1
gen b_lf_religion=b_lf_nonrace if mrk_b2==2
gen b_lf_class=b_lf_nonrace if mrk_b2==3
label variable b_lf_nonrace "Group B: Non-Race Linked Fate: b2 & b3"
label variable b_lf_gender "Group B: Gender Linked Fate: b2 & b3, if mrk_b2=1"
label variable b_lf_religion "Group B: Religion Linked Fate: b2 & b3, if mrk_b2=2"
label variable b_lf_class "Group B: Class Linked Fate: b2 & b3, if mrk_b2=3"

recode b4 2=0
recode b5 3=0 2=1 1=2
gen b_lf_race=b4+b5 
replace b_lf_race=0 if b4==0
replace b_lf_race=1 if b4==1 & b5==.
label variable b_lf_race "Group B: Race Linked Fate: b4 & b5"

*Recode Group C (xtess011=3; primed)

recode c4 2=0
recode c5 3=0 2=1 1=2
gen c_lf_race=c4+c5 
replace c_lf_race=0 if c4==0
replace c_lf_race=1 if c4==1 & c5==.
label variable c_lf_race "Group C: Race Linked Fate: c4 & c5"

*Combining Measures Across Experimental Groups

gen lf_race=a_lf_race if xtess011==1
replace lf_race=b_lf_race if xtess011==2
replace lf_race=c_lf_race if xtess011==3
label variable lf_race "Race Linked Fate"

gen lf_nonrace=a_lf_nonrace if xtess011==1
replace lf_nonrace=b_lf_nonrace if xtess011==2
label variable lf_nonrace "Non-Race Linked Fate"

gen lf_gender=a_lf_gender if xtess011==1
replace lf_gender=b_lf_gender if xtess011==2
label variable lf_gender "Gender Linked Fate"

gen lf_religion=a_lf_religion if xtess011==1
replace lf_religion=b_lf_religion if xtess011==2
label variable lf_religion "Religion Linked Fate"

gen lf_class=a_lf_class if xtess011==1
replace lf_class=b_lf_class if xtess011==2
label variable lf_class "Class Linked Fate"

label define lf 0 "No" 1 "Not Very Much" 2 "Some" 3 "A Lot"

label values lf_race lf 
label values lf_nonrace lf
label values lf_gender lf
label values lf_religion lf
label values lf_class lf

*Creating Indicator Variables for Experimental Groups

gen groupA=(xtess011==1)
gen groupB=(xtess011==2)
gen groupC=(xtess011==3)
label variable groupA "R assigned to Group A (Unprimed, Race First)"
label variable groupB "R assigned to Group B (Unprimed, Race Second)"
label variable groupC "R assigned to Group C (Primed)"

gen txt_Gender=(mrk_a4==1|mrk_b2==1)
gen txt_Religion=(mrk_a4==2|mrk_b2==2)
gen txt_Class=(mrk_a4==3|mrk_b2==3)
replace txt_Gender=. if groupC
replace txt_Religion=. if groupC
replace txt_Class=. if groupC
label variable txt_Gender "R asked about GENDER linked fate"
label variable txt_Religion "R asked about RELIGION linked fate"
label variable txt_Class "R asked about SOCIAL CLASS linked fate"

*Creating Indicator Variables for Demographic Groups

gen white=(ppethm==1)
gen black=(ppethm==2)
gen asian=(ppethm==3)
*NOTE: KN indicated in email that all of "other" is Asian
gen hispanic=(ppethm==4)
label variable white "R is white"
label variable black "R is black"
label variable asian "R is asian"
label variable hispanic "R is hispanic"

gen male=(ppgender==1)
gen female=(ppgender==2)
label variable male "R is male"
label variable female "R is female"

label data "Recode of tess2_011_hochschild_final_data"
save "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/tess2_011_hochschild_r3may10.dta", replace

gen lower=(a1==1|b1==1)
gen working=(a1==2|b1==2)
gen middle=(a1==3|b1==3)
gen upper=(a1==4|b1==4)
label variable lower "R is 'lower class' (a1/b1)"
label variable working "R is 'working class' (a1/b1)"
label variable middle "R is 'middle class' (a1/b1)"
label variable upper "R is 'upper class' (a1/b1)"

gen christian=(xrel1==1|xrel1==2|xrel1==3|xrel1==4|xrel1==9|xrel1==10|xrel1==11)
gen nonchristian=(xrel1==5|xrel1==6|xrel1==7|xrel1==8|xrel1==12)
gen noreligion=(xrel1==13)
label variable christian "R has Christian religion (xrel1)"
label variable nonchristian "R has Non-Christian religion (xrel1)"
label variable noreligion "R has No Religion (xrel1)"

gen attendreligion1xm=(xrel2<4)
gen attendreligionlt1xm=(xrel2==4|xrel2==5)
gen noattendreligion=(xrel2==6)
label variable attendreligion1xm "R attends religious services at least 1-2/month (xrel2)"
label variable attendreligionlt1xm "R attends religious services less than 1/month (xrel2)"
label variable noattendreligion "R never attends religious services (xrel2)"

note: Added indicator variables for class and religion to version rMay10

save "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/tess2_011_hochschild_r27may10.dta", replace


*Add in additional variables provided by TESS, August 2010 (March 2011)
*-----------------------------------------------------------------------
clear

use "/Users/cgay/Documents/My Documents/Linked Fate/TESS DATA/tess2_011_hochschild_final_data_081110.dta"
keep caseid pppa* pphi*
sort caseid
save "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/d5.dta"

clear

use "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/tess2_011_hochschild_r27may10.dta"
sort caseid
merge caseid using  "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/d5.dta"
drop _merge

label data "Recode of tess2_011_hochschild_final_data with _081110 data added"

note: Added pppa* and pphi* variables to version r27may10

save "/Users/cgay/Documents/My Documents/Linked Fate/Analysis/Recoded Data/tess2_011_hochschild_r30Mar11.dta"

clear